package com.hanamaki.databaseTest.util;


import java.sql.*;

public class JDBCUtilTest_DBCP {
    static Connection connection;
    static Statement statement;
    static ResultSet resultSet;
    static PreparedStatement preparedStatement;


    static void test1() {
        // 通过工具类连接数据库
        try {
            connection = JDBCUtil_DBCP.getCon();
            statement = connection.createStatement();
            String sql = "SELECT * from students";
            resultSet = statement.executeQuery(sql);
            while (resultSet.next()) {
                System.out.println(resultSet.getObject("age"));
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        // 释放资源
        JDBCUtil.release(connection, resultSet, statement, null);

    }


    public static void main(String[] args) throws SQLException {

        test1();

    }



}
